import type { LoginMember } from "@/types/LoginMember";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useMemberStore = defineStore('token',()=>{
  const profile = ref<LoginMember>()

  //保存
  const setProfile = (val: LoginMember) => {
    profile.value = val;
  }

  // 清除
  const clearProfile = () => {
    profile.value = undefined;
  }

  return {
    profile,
    setProfile,
    clearProfile,
  }
},
{
  // 小程序端配置
  persist:{
    storage:{
      getItem(key) {
        return uni.getStorageSync(key)
      },
      setItem(key, value) {
        uni.setStorageSync(key, value)
      }
    }
  }
})